/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ibmmodel3;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author mwh
 */
public class DistortionKey {

    final int TargetPos; // j

    final int SourcePos; // a_j

    final int TargetLength; // m;

    final int SourceLength; // l;

    final int hash;

    final List<Integer> listRep;


    public DistortionKey(int SourcePos, int TargetPos, int SourceLength, int TargetLength) {
        this.TargetPos = TargetPos;
        this.SourcePos = SourcePos;
        this.TargetLength = TargetLength;
        this.SourceLength = SourceLength;
        hash = SourcePos + 100 * TargetPos + 10000 * SourceLength + 1000000 * TargetLength;

      listRep = new ArrayList<Integer>(4);
        listRep.add(0, SourcePos);
        listRep.add(1, TargetPos);
        listRep.add(2, SourceLength);
        listRep.add(3, TargetLength);
        

    }


    public List<Integer> asList() {
        return listRep;
    }


    @Override
    public String toString() {
        return SourcePos + "," + TargetPos + "," + SourceLength + "," + TargetLength;
    }


    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final DistortionKey other = (DistortionKey) obj;
        if (this.TargetPos != other.TargetPos) {
            return false;
        }
        if (this.SourcePos != other.SourcePos) {
            return false;
        }
        if (this.TargetLength != other.TargetLength) {
            return false;
        }
        if (this.SourceLength != other.SourceLength) {
            return false;
        }
        return true;
    }


    @Override
    public int hashCode() {

        return hash;
    }
}
